<?
include_once '../tools/DbTools.php';
session_start();

include_once '../common/common.php';
$token = $_COOKIE['Token'];
$CardNo = $_SESSION[$token]['username'];
//初始化数据库连接
DbTools::init();
$Sql = "select CardMoney from bankcard where CardId=".$_SESSION[$token]['CardId'];
$result = DbTools::select($Sql);
$money = $result[0]['CardMoney'];
$money=(float)$money;

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
</head>
<body>
<form action="" method="post">
    余&nbsp;&nbsp;&nbsp;额: <input type="text" name="num1" id="" value="<? echo $money.'.0000'?> "  disabled="true"/>
    <br>
    取出金额: <input type="text " name="num2" value="" />
    <br>
    <input type="submit" value="提交"/>
</form>
<?php
$num=$_POST['num2'];
$num=(float)$num;

$sum=$money-$sum;
$sql="update bankcard set CardMoney='$sum' where CardNo= ".$CardNo;

$results=DbTools::noSelect($sql);
if($results[2]['status']){
    echo "<script>alert('取钱成功')</script>";
}

//关闭连接
DbTools::close();
?>
</body>

</html>
